import { defineStore } from "pinia";
import type { Edge as VFEdge, Node as VFNode } from "@vue-flow/core";

export const useMyVflowStore = defineStore({
  id: "myVflowStore",
  state: () => ({
    vfNodes: [] as VFNode[],
    vfEdges: [] as VFEdge[],
  }),
  actions: {
    addVfNode(node: VFNode) {
      this.vfNodes.push(node);
    },
    addVfEdge(edge: VFEdge) {
      this.vfEdges.push(edge);
    },
    resetNodes() {
      // ! with some warning
      this.vfNodes = [];
    },
    resetEdges() {
      // ! with some warning
      this.vfEdges = [];
    },
    resetAll() {
      this.resetEdges();
      this.resetNodes();
    },
  },
  getters: {
    isVFEmpty: store => store.vfNodes.length === 0, // && store.vfEdges.length === 0, edge 不为0 没关系
  },
});
